package file;

import java.io.*;
import java.util.*;

public class AllFolderHtml {

	private static void checkAndMake(String folder, String makefolder) throws IOException {
		String[] foldernames = FileChanger.fileNames(folder);
		Arrays.sort(foldernames);
		for(int i=0;i<foldernames.length;i++){
			if(!(new File(foldernames[i])).isDirectory())continue;
			String name = makefolder.concat("/").concat((new File(foldernames[i]).getName())).concat(".html");
			String[] filenames = 
				FileChanger.specificSort(FileChanger.fileNames(foldernames[i]),".jpg");
			File makefile = new File(name);
			if(!makefile.exists()){
				FileChanger.MakeListHtml(makefile, filenames);
			}else{
				System.out.println("すでに存在するファイルです");
			}
		}
	}
	
	public static void main(String args[]) throws IOException{
		System.out.println("探索フォルダ");
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String path = br.readLine();
		System.out.println("作成フォルダ");
		String make = br.readLine();
		checkAndMake(path, make);
	}
}
